import request from '@/utils/request'

// 获取任务列表
export function getTaskInfoList(query) {
  return request({
    url: '/project/taskInfo/paging',
    method: 'get',
    params: query
  })
}

// 保存任务
export function saveTaskInfo(task) {
  return request({
    url: '/project/taskInfo/saveTaskAll',
    method: 'post',
    data: task
  })
}
// 删除任务
export function deleteTaskInfo(taskId) {
  return request({
    url: '/project/taskInfo/delete',
    method: 'post',
    params: { taskId }
  })
}

// 查询一级类目名称
export function getOneCategory(categoryId) {
  return request({
    url: '/project/taskInfo/getOneCategory',
    method: 'post',
    params: { categoryId }
  })
}
// 获取一级类目集合
export function getTaskOneCategoryList() {
  return request({
    url: '/project/taskInfo/getTaskOneCategoryList',
    method: 'post',
    params: { }
  })
}

// 查询一级分类下的所有二级、三级分类
export function getCategoryList(categoryId) {
  if (!categoryId) {
    return false
  }
  return request({
    url: '/project/taskInfo/listCategory',
    method: 'get',
    params: { categoryId: categoryId }
  })
}

// 获取任务信息详情
export function getTaskInfo(taskId) {
  return request({
    url: '/project/taskInfo/getTaskInfo',
    method: 'get',
    params: { taskId }
  })
}

// 等级集合
export function getListTaskLevel(taskId) {
  return request({
    url: '/project/taskLevel/listTaskLevel',
    method: 'get',
    params: { taskId }
  })
}

// 协同任务统计 任务需求微客 数量
export function countTaskMember(taskId) {
  return request({
    url: '/project/taskMember/countTaskMember',
    method: 'get',
    params: { taskId }
  })
}

// 统计已支付金额
export function countAmount(taskId) {
  return request({
    url: '/project/taskStage/countAmount',
    method: 'get',
    params: { taskId }
  })
}

// 统计报名列表数、录用列表数、验收记录列表数、任务日志列表数
export function countListNum(taskId) {
  return request({
    url: '/project/taskInfo/countListNum',
    method: 'get',
    params: { taskId }
  })
}

// 保存任务详情
export function updateTaskDetail(query) {
  return request({
    url: '/project/taskDetail/save',
    method: 'post',
    data: query
  })
}

// 查询招募员集合
export function listRecruiterList(enterpriseId) {
  if (!enterpriseId) {
    return false
  }
  return request({
    url: '/project/taskInfo/listRecruiterList',
    method: 'get',
    params: { enterpriseId: enterpriseId }
  })
}
// 查询选择推送的招募员
export function listPushMemberList(enterpriseId) {
  return request({
    url: '/project/taskInfo/listPushMemberList',
    method: 'get',
    params: { enterpriseId }
  })
}

// 查询初始化数据
export function getTaskInfoDetail(taskId) {
  if (!taskId) {
    return false
  }
  return request({
    url: '/project/taskInfo/getTaskInfoDetail',
    method: 'get',
    params: { taskId: taskId }
  })
}

// 停止任务
export function stopTaskInfo(taskId) {
  if (!taskId) {
    return false
  }
  return request({
    url: '/project/taskInfo/stopTaskInfo',
    method: 'post',
    params: { taskId }
  })
}

// 获取任务列表
export function pagingTaskPoster(query) {
  return request({
    url: '/project/taskInfo/pagingTaskPoster',
    method: 'get',
    params: query
  })
}

// 停止任务
export function updateTaskPosterStatus(taskDetailIds, status) {
  return request({
    url: '/project/taskInfo/updateTaskPosterStatus',
    method: 'post',
    data: {
      taskDetailIds: taskDetailIds,
      posterStatus: status
    }
  })
}

// 更改任务状态
export function saveTaskInfoStatus(task) {
  return request({
    url: '/project/taskInfo/updateTaskStatus',
    method: 'post',
    params: task
  })
}

// 获取任务状态
export function getTaskInfoDict(groupName) {
  return request({
    url: '/common/getListDictByGroupName',
    method: 'get',
    params: { groupName }
  })
}

// 结束报名 校验是否有未签约的人 true false
export function doSignEnd(taskId) {
  return request({
    url: '/project/taskMember/doSignEnd',
    method: 'get',
    params: { taskId }
  })
}

// 财务追加酬金待托管 分页
export function pagingAppendAmount(query) {
  return request({
    url: '/project/taskInfo/pagingAppendAmount',
    method: 'get',
    params: query
  })
}

// 获取数据任务类型
export function getEditTaskType(query) {
  return request({
    url: '/project/taskInfo/getEditTaskType',
    method: 'get',
    params: query
  })
}

export function getEditTaskInfo(query) {
  return request({
    url: '/project/taskInfo/getTaskInfo',
    method: 'get',
    params: query
  })
}
